﻿
using System;
using System.Security.Permissions;
using System.Windows.Forms;

namespace WHC.OrderWater.Commons
{
    /// <summary>Provides properties for getting information about the format and configuration of the mouse installed on the local computer.</summary>
    [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
    public class MouseHelper
    {
        #region Properties

        /// <summary>Gets a Boolean that indicates if the mouse is installed.</summary>
        /// <returns>A Boolean with value True if the mouse is installed; otherwise False.</returns>
        public static bool MousePresent
        {
            get
            {
                return SystemInformation.MousePresent;
            }
        }

        /// <summary>Gets a Boolean that indicates if the mouse has a scroll wheel.</summary>
        /// <returns>A Boolean with value True if the mouse has a scroll wheel; otherwise False.</returns>
        public static bool WheelExists
        {
            get
            {
                if (!SystemInformation.MousePresent)
                {
                    throw new InvalidOperationException("No mouse is present.");
                }
                return SystemInformation.MouseWheelPresent;
            }
        }

        /// <summary>Gets a number that indicates how much to scroll when the mouse wheel is rotated one notch.</summary>
        /// <returns>An Integer that indicates how much to scroll when the mouse wheel is rotated one notch. A positive value indicates scrolling by that number of lines, while a negative value indicates scrolling by one screen at a time.</returns>
        /// <filterpriority>1</filterpriority>
        public static int WheelScrollLines
        {
            get
            {
                if (!WheelExists)
                {
                    throw new InvalidOperationException("No mouse wheel is present.");

                }
                return SystemInformation.MouseWheelScrollLines;
            }
        }

        #endregion
    }
}
